package com.xk._03真题骗._04字符串;

/*
 * @description: https://leetcode.cn/problems/valid-anagram/
 * @author: xu
 * @date: 2022/11/1 10:51
 */
public class _242有效的字母异位词 {
    public boolean isAnagram(String s, String t) {
        if (s == null || t == null) return false;
        if (s.length() != t.length()) return false;
        int[] count = new int[26];
        for (char c : s.toCharArray()) {
            count[c - 'a']++;
        }
        for (char c : t.toCharArray()) {
            count[c - 'a']--;
        }
        for (int i : count) {
            if (i != 0) return false;
        }
        return true;
    }
}
